<?php
/**
 * Created by PhpStorm.
 * User: Xwen
 * Date: 2018/12/19
 * Time: 22:14
 *
 *          ┌─┐       ┌─┐
 *       ┌──┘ ┴───────┘ ┴──┐
 *       │                 │
 *       │       ───       │
 *       │  ─┬┘       └┬─  │
 *       │                 │
 *       │       ─┴─       │
 *       │                 │
 *       └───┐         ┌───┘
 *           │         │
 *           │         │
 *           │         │
 *           │         └──────────────┐
 *           │                        │
 *           │                        ├─┐
 *           │                        ┌─┘
 *           │                        │
 *           └─┐  ┐  ┌───────┬──┐  ┌──┘
 *             │ ─┤ ─┤       │ ─┤ ─┤
 *             └──┴──┘       └──┴──┘
 *                 神兽保佑
 *                 代码无BUG!
 *"The trouble with programmers is that you can never tell what a programmer is doing until it’s too late.”- Seymour Cray
 */

namespace app\admin\validate;


use think\Validate;

class Menu extends Validate
{
    protected $rule = [
        'id'            =>  'require|integer',
        'pid'           =>  'require|integer',
        'menu_name'     =>  'require|min:2',
        'menu_icon'     =>  'require',
        'controller'    =>  'require',
        'method'        =>  'require'
    ];

    protected $message = [
        'id.require'            =>  '缺少菜单ID',
        'id.integer'            =>  '菜单ID必须是整数',
        'pid.require'           =>  '缺少菜单父ID',
        'pid.integer'           =>  '菜单父ID必须是整数',
        'menu_name.require'     =>  '缺少菜单名',
        'menu_name.min'         =>  '菜单名至少两位',
        'menu_icon.require'     =>  '一级菜单必须有图标',
        'controller.require'    =>  '缺少控制器名',
        'method.require'        =>  '缺少方法名'
    ];

    protected $scene = [
        'addOne'    =>  ['pid', 'menu_name', 'menu_icon'],
        'addTwo'    =>  ['pid', 'menu_name', 'controller', 'method'],
        'editOne'   =>  ['id', 'pid', 'menu_name', 'menu_icon'],
        'editTwo'   =>  ['id', 'pid', 'menu_name', 'controller', 'method'],
        'delete'   =>  ['id'],
    ];

}